<template>
  <div id="" name="">
    <van-nav-bar
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
    />
    <button v-if="username" @click="clearToken">退出登录</button>
    <button @click="log" v-else>登录</button>
  </div>
</template>
<script>
export default {
  name: '',
  props: {},
  data() {
    return {
      username: '',
    };
  },
  // 子组件转换
  components: {},
  // 数据引入
  mounted() {
  },
  created() {
    this.username=localStorage.getItem('token')
  },
  //点击函数事件
  methods: {
    onClickLeft() {
      this.$router.back()
    },
    log(){
      this.$router.push('/login')
    },
    clearToken(){
      localStorage.removeItem('token')
      this.$router.go(0)
    }
  },
  //计算事件
  computed: {},
  //数据监听
  watch: {},
  //过滤器
  filters: {},
  //设定自定义指令
  directives: {},
}
</script>
<style lang="scss" scoped>

</style>